<?php
 
  include './myinclude/common.inc.php';

  $g_db = new Mysql_Cls($mysqlConfig);

  //获取手机品牌
  $sql = " SELECT * FROM cj_mobile_brand ";
  $g_db->query($sql);
  while($row = $g_db->fetch_array()){
	  $brandList[] = $row;
  }

  //获取热销手机列表
  $sql = " SELECT * FROM cj_mobile_phone WHERE moep_hot_sale=1  ORDER BY moep_id DESC LIMIT 0,10 ";
  $g_db->query($sql);
  while($row = $g_db->fetch_array()){
	  $hostSalePhone[] = $row;
  }


  //获取手机列表

  $where = '';
  if($_GET['bid'] > 0){
	  $where .= ' AND moeb_id='.intval($_GET['bid']);
  }

  if($_GET['price']){
	  $price = explode('-', $_GET['price']);
	  if($price['1'] > 0){
		  $where .=' AND ( moep_price >= '.$price[0].' AND moep_price <='.$price[1].')';
	  }else{
		  $where .=' AND moep_price >= '.$price[0];
	  }
  }


  $page = $_GET['page'] ? $_GET['page'] : 1 ;
  $perpage = 12;
  $start = ($page-1) * $perpage;
  $limit = 'LIMIT '.$start.','.$perpage;

  $sql   = " SELECT SQL_CALC_FOUND_ROWS * FROM cj_mobile_phone WHERE 1=1  ".$where.' '.$limit;
  $g_db->query($sql);  
  while($row = $g_db->fetch_array()){
	  $phoneList[] = $row;
  }
  $sql = " SELECT FOUND_ROWS() as num";
  $g_db->query($sql);  
  $row = $g_db->fetch_array();
  $countPhone = $row['num'];

  unset($_GET['page']); 
  $query = http_build_query($_GET);
  $pagestr = multi($countPhone, $perpage, $page, '?'.$query);

  include './mytpl/mobile.php';
?>
